import React, { Component } from 'react'

export class Detail extends Component {
    state={
        obj:{},
        shopCar:[]
    }
    componentDidMount(){
        console.log(this.props,"详情");
        let id = this.props.match.params.id
        let newObj = this.props.location.state
        newObj.id = id
        this.setState({obj:newObj})
    }
    render() {
        let {obj} = this.state
        return (
            <div>
                详情页
                id:<p>{obj.id}</p>
                <img src={obj.img} alt=""/>
                <p>{obj.title}</p>
                price <p style={{color:"red"}}> {obj.price}</p>
                count:<p style={{color:"green"}}>{obj.count}</p>
                
            </div>
        )
    }
}

export default Detail
